﻿Ext.ns('suce.suce');

suce.suce.AsignarEvaluador = function (config) {

    return new Ext.Window(Ext.apply({

        title: 'Tomar Control',
        width: 300,
        height: 200,
        modal: true,

        initComponent: function () {
            var me = this,
                form;

            me.addEvents('update');

            me.bbar = ['->',
                { text: '<b>Aceptar</b>', handler: me.ok, scope: me, iconCls: 'tb-ok' },
                { text: 'Cancelar', handler: me.onEsc, scope: me, iconCls: 'tb-exit' }
            ];

            form = new Ext.form.Panel({
                baseCls: 'x-plain',
                bodyPadding: 10,
                fieldDefaults: { anchor: '100%' },
                items: [
                    HIDDEN('idsolicitud'),
                    HIDDEN('idflujo'),
                    HIDDEN('idversion'),
                    TEXT('evaluador', 'Evaluador', 500, { readOnly: true, value: SysConfig.vcnombre || SysConfig.nombadm })
                  ]
            });

            me.items = [form];
            Ext.Window.prototype.initComponent.call(me);
            me.form = form.form;
        },

        show: function (p) {
            var me = this;

            Ext.Window.prototype.show.call(me);
            me.form.reset();
            me.form.setValues(p);
        },

        ok: function () {
            var me = this,
                p;
            if (!ISVALID(me.form)) return;
            p = Ext.apply({ C: 'SUCE', S: 'ASIGNAREVALUADOR' }, me.form.getValues());
            postServer('gestor/servicio.ashx', p, function (v) {
                me.fireEvent('update', p);
                me.onEsc();
            }, me);
        }

    }, config));
};
